We can specify the browsers, how long time to keep css ,JS and images stored locally using the .htaccess file i.e( leverage browser caching of static assets). Using google PageSpeed Insights, we can find out how to make our web pages faster on all devices, after giving the web page URL on the text box and clicking the analyze button.
You have to add the following text to the .httaccess file. It will instruct the browser to load previously downloaded resources from the local disk rather than over the network.
Leverage browser caching htaccess code:
# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault"access plus 10 days"
ExpiresByType text/css"access plus 1 week"
ExpiresByType text/plain"access plus 1 month"
ExpiresByType image/gif"access plus 1 month"
ExpiresByType image/png"access plus 1 month"
ExpiresByType image/jpeg"access plus 1 month"
ExpiresByTypeapplication/x-javascript "access plus 1 month"
ExpiresByTypeapplication/javascript "access plus 1 week"
ExpiresByTypeapplication/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES
But for Godaddy windows hosting, it will not work. So,you need to create caching rules in web.config configuration file to enhance the website speed.
System webserver caching:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseExpires"
httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" />
</staticContent>
</system.webServer>
</configuration>
Also add the following code at the top of the .htaccess file.
<IfModule pagespeed_module>
ModPagespeed on
# using commands,filters etc
</IfModule>
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article